Skip to content

Conversation

@jorgenfj
Copy link
Contributor

@jorgenfj jorgenfj commented Dec 9, 2025

reference_to_pose is templated for now, to avoid a dependency on vortex_msgs.
Can therefore be called like this:

pose = vortex::utils::ros_conversions::reference_to_pose(reference);

@jorgenfj jorgenfj requested a review from Andeshog December 9, 2025 14:08
@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.03%. Comparing base (c409297) to head (986c798).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #19      +/-   ##
==========================================
+ Coverage   97.86%   98.03%   +0.17%     
==========================================
  Files           4        5       +1     
  Lines         374      407      +33     
  Branches       72       87      +15     
==========================================
+ Hits          366      399      +33     
  Misses          4        4              
  Partials        4        4              
Flag Coverage Δ
unittests 98.03% <100.00%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
include/vortex/utils/ros_conversions.hpp 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@Andeshog Andeshog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some tests also and I will be very happy

Comment on lines 10 to 22
template <typename T>
geometry_msgs::msg::Pose reference_to_pose(const T& ref) {
geometry_msgs::msg::Pose pose;
pose.position.x = ref.x;
pose.position.y = ref.y;
pose.position.z = ref.z;

tf2::Quaternion q;
q.setRPY(ref.roll, ref.pitch, ref.yaw);
pose.orientation = tf2::toMsg(q);

return pose;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use a simple concept to constrain the input type in a better way. Something like

template <typename T>
concept PoseLike = requires(const T& t) {
    { t.x }     -> std::convertible_to<double>;
    { t.y }     -> std::convertible_to<double>;
    { t.z }     -> std::convertible_to<double>;
    { t.roll }  -> std::convertible_to<double>;
    { t.pitch } -> std::convertible_to<double>;
    { t.yaw }   -> std::convertible_to<double>;
};

template <PoseLike T>
geometry_msgs::msg::Pose reference_to_pose(const T& ref) {
    geometry_msgs::msg::Pose pose;
    pose.position.x = ref.x;
    pose.position.y = ref.y;
    pose.position.z = ref.z;

    tf2::Quaternion q;
    q.setRPY(ref.roll, ref.pitch, ref.yaw);
    pose.orientation = tf2::toMsg(q);

    return pose;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I would say it is not strictly necessary to use tf2 here anymore, since we are packing it in a function anyway (so it doesnt hurt if the function is longer and more verbose).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is purely a ros to ros conversion I don't see why we can't use available ros functions here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can, but why drag in another dependency just because. Also possible to create a separate function that converts Eigen::Quaternion to ros orientation, and then use that directly in reference_to_pose (with euler_to_quat). Also, it isnt really a strict ros to ros conversion, as T can also be Eta from utils here

Comment on lines 1 to 2
#ifndef ROS_CONVERSIONS_HPP
#define ROS_CONVERSIONS_HPP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VORTEX_UTILS_ROS_CONVERSIONS_HPP or something like that

@jorgenfj
Copy link
Contributor Author

jorgenfj commented Dec 9, 2025

Add some tests also and I will be very happy
As it is now I feel that tests for this is overkill. The function is using another function that is already tested. Other than that it just assigns by matching variable names.

@Andeshog
Copy link
Contributor

Add some tests also and I will be very happy
As it is now I feel that tests for this is overkill. The function is using another function that is already tested. Other than that it just assigns by matching variable names.

The thought was more to test that the template works with for instance Eta. Also, documentation 😁

@jorgenfj jorgenfj requested a review from Andeshog December 10, 2025 11:29
Copy link
Contributor

@Andeshog Andeshog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just make the test pass 🍇

@jorgenfj jorgenfj merged commit 32201be into main Dec 10, 2025
5 checks passed
@jorgenfj jorgenfj deleted the feat/reference-to-pose branch December 10, 2025 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants